package cn.wzc.crystal.iam.repository;

import cn.wzc.crystal.iam.entity.IamPerm;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.Set;

public interface PermRepository extends CrudRepository<IamPerm, Long> {

	@Query("select * from IAM_PERM r where r.ID in (" +
		"select iur.ROLE_ID from iam_user_role iur JOIN iam_role_perm irp on iur.ROLE_ID = irp.ROLE_ID where iur.USER_ID=:userId)")
	Set<IamPerm> queryByUser(@Param("userId") Long userId);
}
